package com.prodog.gamemodule.fight.session;

import com.prodog.gamemodule.fight.fightobj.entity.FightObjActInfo;
import lombok.Data;

import java.util.LinkedHashMap;
import java.util.Map;

@Data
public class FightSessionObjInfo {
    private String roundHead = "";
    private String prefix = "";
    private Map<String, FightObjActInfo> actInfos = new LinkedHashMap<>();
    private String suffix = "";
    private String hpTpInfo = "";

    public void addBeActEffectValue(String uuid, String beActUuid, String name, String msg, long value) {
        if (actInfos.get(uuid) == null) {
            actInfos.put(uuid, new FightObjActInfo());
        }
        actInfos.get(uuid).addBeActEffectValue(beActUuid, name, msg, value);
    }

    public void addbeActEffectMsg(String uuid, String beActUuid, String name, String msg) {
        if (actInfos.get(uuid) == null) {
            actInfos.put(uuid, new FightObjActInfo());
        }
        actInfos.get(uuid).addbeActEffectMsg(beActUuid, name, msg);
    }

    public void addActEffectValue(String uuid, String beActUuid, String name, String msg, long value) {
        if (actInfos.get(uuid) == null) {
            actInfos.put(uuid, new FightObjActInfo());
        }
        actInfos.get(uuid).addActEffectValue(beActUuid, name, msg, value);
    }

    public void addActEffectMsg(String uuid, String beActUuid, String name, String msg) {
        if (actInfos.get(uuid) == null) {
            actInfos.put(uuid, new FightObjActInfo());
        }
        actInfos.get(uuid).addActEffectMsg(beActUuid, name, msg);
    }

    public void addBeActInfo(String uuid, String beActUuid, String content) {
        if (actInfos.get(uuid) == null) {
            actInfos.put(uuid, new FightObjActInfo());
        }
        actInfos.get(uuid).addBeActInfo(beActUuid, content);
    }

    public void addHpAbsore(String uuid, long value) {
        if (actInfos.get(uuid) == null) {
            actInfos.put(uuid, new FightObjActInfo());
        }
        actInfos.get(uuid).addHpAbsore(value);
    }

    public void addMpAbsore(String uuid, long value) {
        if (actInfos.get(uuid) == null) {
            actInfos.put(uuid, new FightObjActInfo());
        }
        actInfos.get(uuid).addMpAbsore(value);
    }

    public void setActPrefix(String uuid, String prefix) {
        if (actInfos.get(uuid) == null) {
            actInfos.put(uuid, new FightObjActInfo());
        }
        actInfos.get(uuid).setPrefix(prefix);
    }

    public void setActContent(String uuid, String content) {
        if (actInfos.get(uuid) == null) {
            actInfos.put(uuid, new FightObjActInfo());
        }
        actInfos.get(uuid).setContent(content);
    }

    public String getInfo() {
        StringBuilder sb = new StringBuilder();
        sb.append(roundHead).append(prefix);
        actInfos.values().forEach(info -> sb.append(info.info()).append("\n"));
        sb.append(suffix).append(hpTpInfo);
        return sb.toString();
    }
}
